<?xml version="1.0" encoding="UTF-8" ?>
<%@page import="com.baoyanghui.config.Configs"%>
<%@page import="com.baoyanghui.model.Merchant"%>
<%@page import="com.baoyanghui.common.DataChanger"%>
<%@page import="com.baoyanghui.model.MerchantPlace"%>
<%@page import="java.util.List"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.util.Map"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="com.baoyanghui.common.InterfaceAccess" %>
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<% 
	JSONObject profile = null;
	JSONObject places = null;
	Merchant merchant = null;
	MerchantPlace place = null;
	List<MerchantPlace> placeList = null;
	Map<String, String> params = new HashMap<String, String>();
	
	try {
		request.setCharacterEncoding("UTF-8");
		params.put("merchant_id", (String)session.getAttribute(Configs.SESSION_USER_ID));
		params.put("usercode", (String)session.getAttribute(Configs.SESSION_USERCODE));
		
		profile = InterfaceAccess.callInterface("/merchant/get_profile", params);
		places = InterfaceAccess.callInterface("/merchant/get_places", params);
		merchant = DataChanger.getMerchant(profile);
		placeList = DataChanger.getPlaces(places);
		
		if (merchant == null) {
			response.sendRedirect("login.jsp");
			return;
		}
	} catch (Exception e) {
		response.sendRedirect("login.jsp");
		return;
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link rel="stylesheet" type="text/css" href="../css/style.css"/>
		<script type="text/javascript" src="../js/merchant_user.js"></script>
		<title>宝养汇</title>
	</head>
	<body>
		<jsp:include page="../common/header.jsp"></jsp:include>
		<div id="div_content">
			<div align="left">
				<div style="width: 150px; float: left;">
					<img src="../image/add_image.png" width="128px" height="105px"/><br/>
					<form action="<%= request.getContextPath() %>WS/upload_image" enctype="multipart/form-data" method="post">
						<input type="file" name="image_file" style="width: 95px;"/>
						<input type="submit" value="上传"/>
					</form>
				</div>
			<% if ("0".equals(merchant.getAuthenticationFlg())) {%>
				<div align="center" style="width: 200px; float: left; margin-top: 8px;">
					<img src="../image/unauthed.png"/><br/>
					<img src="../image/btn_auth.png" style="cursor: pointer; margin-top: 6px;"/><br/>
				</div>
			<% } else if ("1".equals(merchant.getAuthenticationFlg())) {%>
				<div align="center" style="width: 200px; float: left; margin-top: 8px;">
					<img src="../image/authed.png"/><br/>
					<img src="../image/btn_authed.png" style="cursor: pointer; margin-top: 6px;"/><br/>
				</div>
			<% } %>
				<div style="clear: both;"></div>
			</div>
			
<%
	if (placeList != null) {
		for (int i = 0; i < placeList.size(); i++) {
			place = placeList.get(i);
%>
			<div align="left" style="padding: 10px 20px;">
				<span style="width: 80px;">场所名称：</span>
				<span style="width: 200px;"><%= place.getPlaceName() %></span>
				<span style="width: 80px;">场所联系人：</span>
				<span style="width: 200px;"><%= place.getLinkMan() %></span>
				<span style="width: 80px;">固定电话：</span>
				<span style="width: 200px;"><%= place.getOfficePhone() %></span><br/>
				<span style="width: 80px;">场所地址：</span>
				<span style="width: 800px;"><%= place.getAddress() %></span><br/>
				<span style="width: 80px;">经营项目：</span>
				<p style="padding-left: 10px;"><%= place.getAddress() %></p>
			</div>
<%
		}
	}
%>
		</div>
		<jsp:include page="../common/footer.jsp"></jsp:include>
	</body>
</html>